/**
 * Created by gek on 2016/3/4.
 */
var appControllers = angular.module('appControllers', []);

appControllers.controller('indexController', function ($scope, $location) {
  $scope.pages = [{
    name: '首页',
    path: '#/'
  }, {
    name: '社区',
    path: '#/articleList'
  }, {
    name: '关于',
    path: '#/about'
  }, {
    name: '帮助',
    path: '#/help'
  }];
  $scope.curPage = {
    '/': 0,
    '/articleList': 1,
    '/articleInfo': 1,
    '/about': 2,
    '/help': 3
  }[$location.path().slice(0, $location.path().indexOf('/', 2))];
});

appControllers.controller('articleController', function ($scope, $location, $routeParams) {
  if ($location.path() == '/articleList') {
    $scope.path = 'articleList.html';
    $scope.docs = [{
      id: 1,
      title: '明月松间照，清泉石上流',
      author: '王维',
      date: '2015-12-24',
      image: 'http://image.cheerby.cn/articleHomePageImg/20151217181717087056.jpg',
      abstract: '我是文章摘要'
    }, {
      id: 2,
      title: '竹喧归浣女，莲动下渔舟',
      author: '王维',
      date: '2015-12-25',
      image: 'http://image.cheerby.cn/articleHomePageImg/20151217181717087056.jpg',
      abstract: '我是中心思想'
    }];

  } else {
    $scope.path = 'articleInfo.html';
    var id = $routeParams.id;

    $scope.doc = {
      id: id,
      title: id + '竹喧归浣女，莲动下渔舟',
      author: '王维',
      content: '',
      time: '2015-08-18'
    };

  }
});

appControllers.controller('commentController', function ($scope) {
  $scope.toggle = function () {
    $scope.comment = !$scope.comment;
  }
});
